<?php

namespace Weapp\Product;

use Weapp\Basic\Basic;

/**
 * 商家地址管理接口
 * Class Order
 * @url https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/business-capabilities/ministore/minishopopencomponent/API/address/add_address.html
 * @package Weapp/Product
 */
class Address extends Basic
{
    /**
     * 添加商家地址
     * @param array $data
     * @return array
     * @throws \Weapp\Exceptions\InvalidResponseException
     * @throws \Weapp\Exceptions\LocalCacheException
     */
    public function add($data)
    {
        $url = 'product/address/add';
        $this->registerApi($url, __FUNCTION__, func_get_args());
        return $this->callPostApi($url, $data, true);
    }

    /**
     * 删除商家地址
     * @param array $data
     * @return array
     * @throws \Weapp\Exceptions\InvalidResponseException
     * @throws \Weapp\Exceptions\LocalCacheException
     */
    public function delete($data)
    {
        $url = 'product/address/delete';
        $this->registerApi($url, __FUNCTION__, func_get_args());
        return $this->callPostApi($url, $data, true);
    }
    /**
     * 获取商家地址
     * @param array $data
     * @return array
     * @throws \Weapp\Exceptions\InvalidResponseException
     * @throws \Weapp\Exceptions\LocalCacheException
     */
    public function get($data)
    {
        $url = 'product/address/get';
        $this->registerApi($url, __FUNCTION__, func_get_args());
        return $this->callPostApi($url, $data, true);
    }
    /**
     * 更新商家地址
     * @param array $data
     * @return array
     * @throws \Weapp\Exceptions\InvalidResponseException
     * @throws \Weapp\Exceptions\LocalCacheException
     */
    public function update($data)
    {
        $url = 'product/address/update';
        $this->registerApi($url, __FUNCTION__, func_get_args());
        return $this->callPostApi($url, $data, true);
    }
}
